package cn.com.demo.microservice.anquan.mapper;

import cn.com.demo.microservice.entity.AqUser;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

public class AqUserSqlProvider {

    public String insertSelective(AqUser record) {
        BEGIN();
        INSERT_INTO("aq_user");
        
        if (record.getUrId() != null) {
            VALUES("ur_id", "#{urId,jdbcType=INTEGER}");
        }
        
        if (record.getUrName() != null) {
            VALUES("ur_name", "#{urName,jdbcType=VARCHAR}");
        }
        
        if (record.getUrPhone() != null) {
            VALUES("ur_phone", "#{urPhone,jdbcType=VARCHAR}");
        }
        
        if (record.getUrSex() != null) {
            VALUES("ur_sex", "#{urSex,jdbcType=CHAR}");
        }
        
        if (record.getUrAvatar() != null) {
            VALUES("ur_avatar", "#{urAvatar,jdbcType=VARCHAR}");
        }
        
        if (record.getUrIntroduction() != null) {
            VALUES("ur_introduction", "#{urIntroduction,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(AqUser record) {
        BEGIN();
        UPDATE("aq_user");
        
        if (record.getUrName() != null) {
            SET("ur_name = #{urName,jdbcType=VARCHAR}");
        }
        
        if (record.getUrPhone() != null) {
            SET("ur_phone = #{urPhone,jdbcType=VARCHAR}");
        }
        
        if (record.getUrSex() != null) {
            SET("ur_sex = #{urSex,jdbcType=CHAR}");
        }
        
        if (record.getUrAvatar() != null) {
            SET("ur_avatar = #{urAvatar,jdbcType=VARCHAR}");
        }
        
        if (record.getUrIntroduction() != null) {
            SET("ur_introduction = #{urIntroduction,jdbcType=VARCHAR}");
        }
        
        WHERE("ur_id = #{urId,jdbcType=INTEGER}");
        
        return SQL();
    }
}